<?php
namespace Admin\Controller;
use Admin\Controller\AdminController;
class FylprojectController extends AdminController{
	public function _initialize(){
		parent::_initialize();
	}
	/**
	 * 查询fly
	 */
	public function queryFly(){
		$where = [];
		$uid = I('uid');
		if(!empty($uid)){
			$uid = intval($uid);
			$where['f.uid'] = $uid;
		}
		$status = I('status');
		if(!empty($status)){
			if(!in_array($status, [0,1])){
				$data = [
				'status'=>-1,
				'msg'=>'状态参数错误'
						];
				$this->ajaxReturn($data);
			}
			$where['f.status'] = $status;
		}
		$loginName = I('loginName');
		if(!empty($loginName)){
			$where['u.loginName'] = ['like','%'.$loginName.'%'];
		}
		$userPhone = I('userPhone');
		if(!empty($userPhone)){
			$where['u.userPhone'] = ['like','%'.$userPhone.'%'];
		}
		$add_time = I('add_time');
		if(!empty($add_time)){
			$add_time==1?$order = 'f.add_time':$order = 'f.add_time desc';
		}
		$page = I('page');
		$num = I('num');
		$begin = I('begin');
		$last = I('last');
		$times = dotime($begin, $last);
		$where['add_time'] = ['between',[$times['begin'],$times['last']]];
		$pages = DoPage($page, $num);
		$r = M('Fyl_project')
			->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->field('f.*,u.loginName,u.userPhone,u.userId')
			->limit($pages['limit'],$pages['num'])
			->where($where)
			->select();
		$count = M('Fyl_project')
			->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->where($where)
			->count();
		$this->ajaxReturn(['status'=>1,'data'=>$r,'count'=>$count]);
	}
	/**
	 * 查询日志
	 */
	public function queryWallet(){
		$uid = I('uid');
		if(!empty($uid)){
			$uid = intval($uid);
			$where['f.uid'] = $uid;
		}
		$type = I('type');
		if(!empty($type)){
			if(!in_array($type,[1,2])){
				$data = [
				'status'=>-1,
				'msg'=>'收支参数错误'
						];
				$this->ajaxReturn($data);
			}
			$where['f.type'] = $type;
		}
		$money_type = I('money_type');
		if(!empty($money_type)){
			if(!in_array($money_type, [1,2,3])){
				$data = [
				'status'=>-1,
				'msg'=>'币种类型参数错误'
						];
				$this->ajaxReturn($data);
			}
			$where['f.money_type'] = $money_type;
		}
		$add_time = I('add_time');
		if(!empty($add_time)){
			$add_time==1?$order = 'f.add_time':$order = 'f.add_time desc';
		}
		$loginName = I('loginName');
		if(!empty($loginName)){
			$where['u.loginName'] = ['like','%'.$loginName.'%'];
		}
		$userPhone = I('userPhone');
		if(!empty($userPhone)){
			$where['u.userPhone'] = ['like','%'.$userPhone.'%'];
		}
		$page = I('page');
		$num = I('num');
		$begin = I('begin');
		$last = I('last');
		$times = dotime($begin, $last);
		$where['add_time'] = ['between',[$times['begin'],$times['last']]];
		$pages = DoPage($page, $num);
		$r = M('Wallet_log')
			->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->field('f.*,u.loginName,u.userPhone,u.userId')
			->limit($pages['limit'],$pages['num'])
			->where($where)
			->select();
		$count = M('Wallet_log')
			->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->where($where)
			->count();
		$this->ajaxReturn(['status'=>1,'data'=>$r,'count'=>$count]);
	}
	public function queryJiangli(){
		$uid = I('uid');
		if(!empty($uid)){
			$uid = intval($uid);
			$where['f.uid'] = $uid;
		}
		$add_time = I('add_time');
		if(!empty($add_time)){
			$add_time==1?$order = 'f.add_time':$order = 'f.add_time desc';
		}
		$loginName = I('loginName');
		if(!empty($loginName)){
			$where['u.loginName'] = ['like','%'.$loginName.'%'];
		}
		$userPhone = I('userPhone');
		if(!empty($userPhone)){
			$where['u.userPhone'] = ['like','%'.$userPhone.'%'];
		}
		$page = I('page');
		$num = I('num');
		$begin = I('begin');
		$last = I('last');
		$times = dotime($begin, $last);
		$where['add_time'] = ['between',[$times['begin'],$times['last']]];
		$pages = DoPage($page, $num);
		$r = M('Jiangli_log')
		->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->field('f.*,u.loginName,u.userPhone,u.userId')
			->limit($pages['limit'],$pages['num'])
			->where($where)
			->select();
		$count = M('Jiangli_log')
			->alias('f')
			->join('__USERS__ AS u on u.userid=f.uid')
			->where($where)
			->count();
		$this->ajaxReturn(['status'=>1,'data'=>$r,'count'=>$count]);
	}
}













